#!/usr/bin/env bash

source ./config/env.sh
clear

mkdir -p ${K8S_DATA}/config/registry-pull/yaml


# 获取稀有镜像base64加密文件
BESE64=`cat ~/.docker/config.json | base64 -w0`


cat > ${K8S_DATA}/config/registry-pull/yaml/registry-pull-secret-default.yaml << EOF
apiVersion: v1
kind: Secret
metadata: 
    name: registry-pull-secret
    namespace: default
data: 
    .dockerconfigjson: ${BESE64}
type: kubernetes.io/dockerconfigjson
EOF

cat > ${K8S_DATA}/config/registry-pull/yaml/registry-pull-secret-kubesystem.yaml << EOF
apiVersion: v1
kind: Secret
metadata: 
    name: registry-pull-secret-kubesystem
    namespace: kube-system
data: 
    .dockerconfigjson: ${BESE64}
type: kubernetes.io/dockerconfigjson
EOF

${K8S_BIN_DIR}/kubectl create -f ${K8S_DATA}/config/registry-pull/yaml/registry-pull-secret-default.yaml
${K8S_BIN_DIR}/kubectl create -f ${K8S_DATA}/config/registry-pull/yaml/registry-pull-secret-kubesystem.yaml

